package com.atguigu.publisher.service.impl;

import com.atguigu.publisher.mapper.DauMapper;
import com.atguigu.publisher.service.PublisherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * StringBoot 业务的实现
 *
 * @author WangJX
 * @version 1.0
 * @date 2019/11/27 18:11
 */
@Service
public class PublisherServiceImpl implements PublisherService {

    @Autowired
    private DauMapper dauMapper;

    //dau 日活
    @Override
    public Long getDauTotal(String date) {
        Long total = dauMapper.getDauTotal(date);
        return total;
    }

    // 分时统计
    @Override
    public Map<String, String> getDauHour(String date) {
        List<Map> dauHour = dauMapper.getDauHour(date);

        Map<String, String> valueMap = new HashMap();
        for (Map map : dauHour) {
            valueMap.put(map.get("loghour").toString(), map.get("ct").toString());
        }

        return valueMap;
    }
}
